/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.bff.designtime.generator.core.extendaction;

import com.inspur.edp.bff.api.attribute.AbstractExtendActionConfig;
import com.inspur.edp.bff.designtime.generator.core.VmCoreGenContext;
import com.inspur.edp.bff.designtime.generator.core.VmCoreHelper;
import com.inspur.edp.bff.designtime.generator.core.extendaction.changemapping.ChangeMapGenerator;
import com.inspur.edp.bff.designtime.generator.core.extendaction.changemapping.ChangeRevsMapGenerator;
import com.inspur.edp.bff.designtime.generator.core.extendaction.delete.AfterDeletePropGenerator;
import com.inspur.edp.bff.designtime.generator.core.extendaction.delete.BeforeDeletePropGenerator;
import com.inspur.edp.bff.designtime.generator.core.extendaction.delete.DeletePropGenerator;
import com.inspur.edp.bff.designtime.generator.core.extendaction.method.ActionConfigCtorGenerator;
import com.inspur.edp.bff.designtime.generator.core.extendaction.modify.AfterModifyPropGenerator;
import com.inspur.edp.bff.designtime.generator.core.extendaction.modify.BeforeModifyPropAssembler;
import com.inspur.edp.bff.designtime.generator.core.extendaction.modify.ModifyPropGenerator;
import com.inspur.edp.bff.designtime.generator.core.extendaction.multidelete.AfterMultiDeletePropGenerator;
import com.inspur.edp.bff.designtime.generator.core.extendaction.multidelete.BeforeMultiDeletePropGenerator;
import com.inspur.edp.bff.designtime.generator.core.extendaction.multidelete.MultiDeletePropGenerator;
import com.inspur.edp.bff.designtime.generator.core.extendaction.property.*;
import com.inspur.edp.bff.designtime.generator.core.extendaction.retrieve.AfterRetrievePropGenerator;
import com.inspur.edp.bff.designtime.generator.core.extendaction.retrieve.BeforeRetrievePropGenerator;
import com.inspur.edp.bff.designtime.generator.core.extendaction.retrieve.RetrievePropGenerator;
import com.inspur.edp.bff.designtime.generator.core.extendaction.retrievedefault.AfterRetrieveDefaultPropGen;
import com.inspur.edp.bff.designtime.generator.core.extendaction.retrievedefault.BeforeRetrieveDefaultPropGen;
import com.inspur.edp.bff.designtime.generator.core.extendaction.retrievedefault.RetrieveDefaultPropGen;
import com.inspur.edp.bff.designtime.generator.core.extendaction.save.AfterSavePropGenerator;
import com.inspur.edp.bff.designtime.generator.core.extendaction.save.BeforeSavePropGenerator;
import com.inspur.edp.caf.generator.baseInfo.TypeInfo;
import com.inspur.edp.caf.generator.field.FieldGenerator;
import com.inspur.edp.caf.generator.item.ClassGenerator;
import com.inspur.edp.caf.generator.item.ClassGeneratorContext;
import com.inspur.edp.caf.generator.method.ClassMethodGenerator;
import com.inspur.edp.caf.generator.property.ClassPropertyGenerator;
import com.inspur.edp.caf.generator.property.PropertyGenerator;
import com.inspur.edp.cef.gencommon.MediateType;
import org.eclipse.jdt.core.dom.Modifier;

import java.util.ArrayList;

public class ActionConfigGenerator extends ClassGenerator {

  //C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
  ///#region Basic Info
  private VmCoreGenContext coreGenCtx;

  public ActionConfigGenerator(VmCoreGenContext coreGenCtx) {
    super(coreGenCtx.getCompilationUnitInfo());
    this.coreGenCtx = coreGenCtx;
  }


  @Override
  protected ClassGeneratorContext createClassInfoContext() {
    return new ClassGeneratorContext();
  }

  @Override
  protected java.util.ArrayList<Modifier.ModifierKeyword> getAccessModifier() {
    return new java.util.ArrayList<Modifier.ModifierKeyword>(
        java.util.Arrays.asList(new Modifier.ModifierKeyword[]{Modifier.ModifierKeyword.PUBLIC_KEYWORD}));
  }

  @Override
  protected TypeInfo setParentClass() {
    return new TypeInfo(AbstractExtendActionConfig.class);
  }

  //C# TO JAVA CONVERTER TODO TASK: Lambda expressions and anonymous methods are not converted by C# to Java Converter:
  @Override
  protected String getName() {
    return coreGenCtx.getVmGenContext().getVm().getCode() + "ActionConfig";
  }

  protected String getNameSpace() {
    return VmCoreHelper.getNamespace(coreGenCtx.getVmGenContext().getVm());
  }

  @Override
  protected void afterGenerate() {
    super.afterGenerate();
    coreGenCtx.setExtendActionConfigType(new MediateType(getNameSpace(), getName()));
  }

//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
  ///#endregion

  @Override
  protected java.util.ArrayList<ClassPropertyGenerator> createPropertyGenerators() {
    ArrayList<ClassPropertyGenerator> list =new ArrayList<>();
    list.add(new BeforeQueryPropGenerator());
    list.add(new QueryPropGenerator());
    list.add(new AfterQueryPropGenerator());
    list.add(new DataMapGenerator());
    list.add(new DataReversalMapGenerator());
    list.add(new BeforeRetrievePropGenerator());
    list.add(new RetrievePropGenerator());
    list.add(new AfterRetrievePropGenerator());
    list.add(new BeforeRetrieveDefaultPropGen());
    list.add(new RetrieveDefaultPropGen());
    list.add(new AfterRetrieveDefaultPropGen());
    list.add(new BeforeModifyPropAssembler());
    list.add(new ModifyPropGenerator());
    list.add(new AfterModifyPropGenerator());
    list.add(new BeforeDeletePropGenerator());
    list.add(new DeletePropGenerator());
    list.add(new AfterDeletePropGenerator());
    list.add(new BeforeSavePropGenerator());
    list.add(new AfterSavePropGenerator());
    list.add(new ChangeMapGenerator());
    list.add(new ChangeRevsMapGenerator());
    list.add(new AfterMultiDeletePropGenerator());
    list.add(new BeforeMultiDeletePropGenerator());
    list.add(new MultiDeletePropGenerator());
    return list;
    //public virtual List<Type> BeforeRetrieveTypes { get; } = new List<Type>();
    //public virtual List<Type> RetrieveTypes { get; } = new List<Type>();
    //public virtual List<Type> AfterRetrieveTypes { get; } = new List<Type>();
    //public virtual List<Type> BeforeRetrieveDefaultTypes { get; } = new List<Type>();
    //public virtual List<Type> RetrieveDefaultTypes { get; } = new List<Type>();
    //public virtual List<Type> AfterRetrieveDefaultTypes { get; } = new List<Type>();
    //public virtual List<Type> BeforeModifyTypes { get; } = new List<Type>();
    //public virtual List<Type> ModifyTypes { get; } = new List<Type>();
    //public virtual List<Type> AfterModifyTypes { get; } = new List<Type>();
    //public virtual List<Type> BeforeDeleteTypes { get; } = new List<Type>();
    //public virtual List<Type> DeleteTypes { get; } = new List<Type>();
    //public virtual List<Type> AfterDeleteTypes { get; } = new List<Type>();
    //public virtual List<Type> BeforeSaveTypes { get; } = new List<Type>();
    //public virtual List<Type> AfterSaveTypes { get; } = new List<Type>();
    //public virtual List<Type> ChangeMapperTypes { get; } = new List<Type>();
    //public virtual List<Type> ChangeReversalMapperTypes { get; } = new List<Type>();
  }

  @Override
  protected ArrayList<FieldGenerator> createFieldGenerator() {
    ArrayList<FieldGenerator> list =new ArrayList<>();
    list.add(new ExtendActionFieldGenerator("BeforeQueryTypesField"));
    list.add(new ExtendActionFieldGenerator("QueryTypesField"));
    list.add(new ExtendActionFieldGenerator("AfterQueryTypesField"));
    list.add(new ExtendActionFieldGenerator("DataMapperTypesField"));
    list.add(new ExtendActionFieldGenerator("DataReversalMapperTypesField"));
    list.add(new ExtendActionFieldGenerator("BeforeRetrieveTypesField"));
    list.add(new ExtendActionFieldGenerator("RetrieveTypesField"));
    list.add(new ExtendActionFieldGenerator("AfterRetrieveTypesField"));
    list.add(new ExtendActionFieldGenerator("BeforeRetrieveDefaultTypesField"));
    list.add(new ExtendActionFieldGenerator("RetrieveDefaultTypesField"));
    list.add(new ExtendActionFieldGenerator("AfterRetrieveDefaultTypesField"));
    list.add(new ExtendActionFieldGenerator("BeforeModifyTypesField"));
    list.add(new ExtendActionFieldGenerator("ModifyTypesField"));
    list.add(new ExtendActionFieldGenerator("AfterModifyTypesField"));
    list.add(new ExtendActionFieldGenerator("BeforeDeleteTypesField"));
    list.add(new ExtendActionFieldGenerator("DeleteTypesField"));
    list.add(new ExtendActionFieldGenerator("AfterDeleteTypesField"));
    list.add(new ExtendActionFieldGenerator("BeforeSaveTypesField"));
    list.add(new ExtendActionFieldGenerator("AfterSaveTypesField"));
    list.add(new ExtendActionFieldGenerator("ChangeMapperTypesField"));
    list.add(new ExtendActionFieldGenerator("ChangeReversalMapperTypesField"));
    list.add(new ExtendActionFieldGenerator("AfterMultiDeleteTypesField"));
    list.add(new ExtendActionFieldGenerator("BeforeMultiDeleteTypesField"));
    list.add(new ExtendActionFieldGenerator("MultiDeleteTypesField"));
    return list;
  }

  @Override
  protected java.util.ArrayList<ClassMethodGenerator> createConstructorGenerators() {
    return new java.util.ArrayList<ClassMethodGenerator>(java.util.Arrays
        .asList(new ClassMethodGenerator[]{new ActionConfigCtorGenerator(coreGenCtx, getName())}));
  }
}
